package com.yipao.db.dao;

import org.apache.ibatis.annotations.Param;
import com.yipao.db.domain.user.User;
import com.yipao.db.domain.YipaoUserExample;

import java.util.List;

/**
 * @author tianhao
 */
public interface UserMapper {

    long countByExample(YipaoUserExample example);


    int deleteByExample(YipaoUserExample example);


    int deleteByPrimaryKey(Integer id);


    int insert(User record);


    int insertSelective(User record);


    User selectOneByExample(YipaoUserExample example);


    User selectOneByExampleSelective(@Param("example") YipaoUserExample example, @Param("selective") User.Column... selective);


    List<User> selectByExampleSelective(@Param("example") YipaoUserExample example, @Param("selective") User.Column... selective);


    List<User> selectByExample(YipaoUserExample example);


    User selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") User.Column... selective);


    User selectByPrimaryKey(Integer id);


    User selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);


    int updateByExampleSelective(@Param("record") User record, @Param("example") YipaoUserExample example);


    int updateByExample(@Param("record") User record, @Param("example") YipaoUserExample example);


    int updateByPrimaryKeySelective(User record);


    int updateByPrimaryKey(User record);


    int logicalDeleteByExample(@Param("example") YipaoUserExample example);


    int logicalDeleteByPrimaryKey(Integer id);

    /**
     * 查询用户绑定的设备id
     *
     * @param id
     * @return
     */
    Integer findDevIdById(Integer id);

    /**
     * 用户绑定设备
     *
     * @param id    用户id
     * @param devId 设备id
     * @return
     */
    int updateUserDevIdById(@Param("id") Integer id, @Param("devId") Integer devId);

    /**
     * 根据用户id查询手机号码
     *
     * @param id      用户id
     * @param deleted 删除状态
     * @return
     */
    String findMobileById(@Param("id") Integer id, @Param("deleted") Integer deleted);
}
